package com.xiaochong.tir.manager.filter;



import javax.servlet.http.HttpSession;

import com.xiaochong.tir.common.data.po.Account;

/**
 * @author xufanglin
 * @date 2017-12-20 20:32
 * Created by xufanglin on 2017/12/20 0020.
 */
public class SessionManager {

    private static final String SESSION_KEY = "session_back_login";

    public static void setLoginSession(HttpSession session, Object object){
        if (session == null || object == null){
            return;
        }
        session.setAttribute(SESSION_KEY, object);
        //设置session失效时间为10小时
        session.setMaxInactiveInterval(36000);
    }

    public static Object getLoginObject(HttpSession session){
        if (session == null){
            return null;
        }
        return session.getAttribute(SESSION_KEY);
    }

    public static Account getLoginAccount(HttpSession session){
        if (session == null){
            return null;
        }
        return (Account)session.getAttribute(SESSION_KEY);
    }
}
